package com.boyiis.sell.converter;

import com.boyiis.sell.model.dto.OrderDTO;
import com.boyiis.sell.model.entity.Order;
import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.stream.Collectors;

public class Order2OrderDtoConverter {
    public static OrderDTO convert(Order order){
        OrderDTO orderDTO = new OrderDTO();
        BeanUtils.copyProperties(order, orderDTO);
        return  orderDTO;
    }


    public static List<OrderDTO> convert(List<Order> orderList){
        return orderList.stream().map(e -> convert(e)).collect(Collectors.toList());
    }

}
